<?php defined('SYSPATH') or die();?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>思途CMS{$coreVersion}</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base_new.css'); }
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,product_add.js,choose.js,st_validate.js,jquery.colorpicker.js,jquery.jqtransform.js,imageup.js"); }
    {php echo Common::getCss('uploadify.css','js/uploadify/'); }
</head>

<body>

<!--顶部-->
{php Common::getEditor('jseditor','',$sysconfig['cfg_admin_htmleditor_width'],500,'Sline','','print',true);}
<table class="content-tab">
    <tr>
        <td width="119px" class="content-lt-td" valign="top">
            {template 'stourtravel/public/leftnav'}
            <!--右侧内容区-->
        </td>
        <td valign="top" class="content-rt-td" style="overflow:auto;">
            <div class="cfg-header-bar">
                <a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
            </div>
            <form id="product_fm">
                <div class="product-add-div" >
                    <ul class="info-item-block">

                        <li class="truename">
                            <span class="item-hd">合同名称：</span>
                            <div class="item-bd">
                                <input type="text" name="title" data-required="true" value="{$info['title']}" class="input-text w900">
	                            <span class="item-text ml-10 c-999">*合同条款内容与思途无关</span>
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">所属产品：</span>
                            <div class="item-bd">
                                <div class="select-box w150">
                                    <select class="select" name="typeid">
                                        <option value="0">请选择</option>
                                        {loop $models $m}
                                        <option value="{$m['id']}" {if $info['typeid']==$m['id']}selected="selected"{/if} >{$m['shortname']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">乙方信息：</span>
                            <div class="item-bd">
                                <div class="select-box w150">
                                    <select class="select" name="partyBid">
                                        {if $default_partyB}
                                        <option value="0">请选择</option>
                                        {/if}
                                        {loop $party $p}
                                        <option value="{$p['id']}" {if $info['partyBid']==$p['id']||(!$info['partyBid']&&$default_partyB==$p['id'])}selected="selected"{/if} >{$p['name']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">合同类型：</span>
                            <div class="item-bd">
                                <div class="select-box w150">
                                    <select class="select" name="type" id="type">
                                        <option value="1" {if $info['type']==1}selected="selected"{/if}>自定义合同</option>
                                        <option value="2" {if $info['type']==2}selected="selected"{/if}>12301合同</option>
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">合同状态：</span>
                            <div class="item-bd">
                                <label class="radio-label"><input type="radio" name="status"  {if $info['status']==1}checked="checked"{/if} value="1">开启</label>
                                <label class="radio-label ml-20"><input type="radio" name="status"  {if $info['status']==0}checked="checked"{/if} value="0">关闭</label>
                            </div>
                        </li>
                        <!--自定义合同内容-->
                        <li>
                            <span class="item-hd">合同条款：</span>
                            <div class="item-bd">
                                <textarea name="content" id="txt_content">{$info['content']}</textarea>
                            </div>
                        </li>
                        <!--自定义合同内容结束-->

                        <!--12301合同内容-->
                        <li class="12301">
                            <span class="item-hd">合同模板类型：</span>
                            <div class="select-box w150">
                                <select class="select" name="templateId">
                                    <option value="A00001" >境内游</option>
                                    <option value="C00001">出境游</option>
                                    <option value="D00001">一日游</option>
                                    <option value="F00001">赴台游</option>
                                    <option value="E00001">代订代办</option>
                                </select>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">签章图片：</span>
                            <div class="item-bd">
                                <a href="javascript:;" id="fx_logo_btn" class="btn btn-primary radius size-S mt-3">上传图片</a>
                                <div id="fx_logo_pic" class="mt-10">
                                    {if !empty($info['content_parameter']['stamp'])}
                                    <img class="up-img-area" src="{$info['content_parameter']['stamp']}">
                                    <input type="hidden" name="stamp" value="{$info['content_parameter']['stamp']}">
                                    {/if}
                                </div>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">是否多人签署：</span>
                            <div class="item-bd">
                                <label class="radio-label"><input type="radio" name="isMultiSignatory"  {if $info['content_parameter']['isMultiSignatory']==1}checked="checked"{/if} value="1">是</label>
                                <label class="radio-label ml-20"><input type="radio" name="isMultiSignatory"  {if $info['content_parameter']['isMultiSignatory']==0}checked="checked"{/if} value="0">否</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">其他约定内容：</span>
                            <div class="item-bd">
                                <textarea class="w500" name="supplementaryClause" id="supplementaryClause_content">{$info['content_parameter']['supplementaryClause']}</textarea>
                            </div>
                        </li>
<!--                        <li class="12301">-->
<!--                            <label>签约社信息travelAgency：</label>-->
<!--                        </li>-->
                        <li class="12301">
                            <span class="item-hd">经办人姓名：</span>
                            <div class="item-bd">
                                <input type="text" name="transactorName" data-required="true" value="{$info['content_parameter']['travelAgency']['transactorName']}" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">经办人电话：</span>
                            <div class="item-bd">
                                <input type="text" name="transactorPhone" data-required="true" value="{$info['content_parameter']['travelAgency']['transactorPhone']}" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">旅行社名称：</span>
                            <div class="item-bd">
                                <input type="text" name="agencyName" data-required="true" value="{$info['content_parameter']['travelAgency']['agencyName']}" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">旅行社许可证号：</span>
                            <div class="item-bd">
                                <input type="text" name="travelAgencyLicenseNumber" data-required="true" value="{$info['content_parameter']['travelAgency']['travelAgencyLicenseNumber']}" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">旅行社工商注册号：</span>
                            <div class="item-bd">
                                <input type="text" name="businessLicenseNumber" data-required="true" value="{$info['content_parameter']['travelAgency']['businessLicenseNumber']}" class="input-text w900">（旅行社统一社会信用代码/工商注册号）
                            </div>
                        </li>

<!--                        <li class="12301">-->
<!--                        <label>签署人信息signatory</label>-->
<!--                        </li>-->
                        <li class="12301">
                                <span class="item-hd">签约方式：</span>
                                <div class="item-bd w150">
                                    <div class="select-box w150">
                                    <select class="select" name="mode">
                                        <option value="1" {if $info['content_parameter']['signatory']['mode']==1}selected="selected"{/if}>线上签约（短信签约）</option>
                                    </select>
                                    </div>
                                </div>
                        </li>
<!--                        <li class="12301">-->
<!--                            <label>解决争议部分dispute</label>-->
<!--                        </li>-->
                        <li class="12301">
                            <span class="item-hd">解决办法：</span>
                            <div class="item-bd w150">
                                <div class="select-box w150">
                                    <select class="select" name="resolution">
                                        <option value="1" {if $info['content_parameter']['dispute']['resolution']==1}selected="selected"{/if}>提交仲裁委员会仲裁</option>
                                        <option value="2" {if $info['content_parameter']['dispute']['resolution']==2}selected="selected"{/if}>向人民法院提起诉讼</option>
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">仲裁委名称：</span>
                            <div class="item-bd">
                                <input type="text" name="tribunalName" data-required="true" value="{$info['content_parameter']['dispute']['tribunalName']}" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">法院名称：</span>
                            <div class="item-bd">
                                <input type="text" name="courtName" data-required="true" value="{$info['content_parameter']['dispute']['courtName']}" class="input-text w900">
                            </div>
                        </li>
<!--                        <li class="12301">-->
<!--                            <label>成团约定部分groupAgreement</label>-->
<!--                        </li>-->
                        <li class="12301">
                            <span class="item-hd">解决办法：</span>
                            <div class="item-bd w150">
                                <div class="select-box w150">
                                    <select class="select" name="groupAgreement_resolution">
                                        <option {if  $info['content_parameter']['groupAgreement']['resolution']==1}selected="selected"{/if} value="1" >委托其他社</option>
                                        <option {if  $info['content_parameter']['groupAgreement']['resolution']==2}selected="selected"{/if} value="2" >延期出团</option>
                                        <option {if  $info['content_parameter']['groupAgreement']['resolution']==3}selected="selected"{/if} value="3" > 改签其他路线</option>
                                        <option {if  $info['content_parameter']['groupAgreement']['resolution']==4}selected="selected"{/if} value="4" >解除合同</option>
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">最低成团人数：</span>
                            <div class="item-bd">
                                <input type="text" name="leastCustomerNumber" data-required="true" value="{$info['content_parameter']['groupAgreement']['leastCustomerNumber']}" class="input-text w900">
                            </div>
                        </li>

                        <li class="12301">
                            <span class="item-hd">委托其它社组团：</span>
                            <div class="item-bd">
                                <label class="radio-label"><input type="radio" name="agreeToTransfer"  {if $info['content_parameter']['groupAgreement']['agreeToTransfer']==1}checked="checked"{/if} value="1">是</label>
                                <label class="radio-label ml-20"><input type="radio" name="agreeToTransfer"  {if $info['content_parameter']['groupAgreement']['agreeToTransfer']==0}checked="checked"{/if} value="0">否</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">是否同意延期：</span>
                            <div class="item-bd">
                                <label class="radio-label"><input type="radio" name="agreeToDelay"  {if $info['content_parameter']['groupAgreement']['agreeToDelay']==1}checked="checked"{/if} value="1">是</label>
                                <label class="radio-label ml-20"><input type="radio" name="agreeToDelay"  {if $info['content_parameter']['groupAgreement']['agreeToDelay']==0}checked="checked"{/if} value="0">否</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">可改为其它线路：</span>
                            <div class="item-bd">
                                <label class="radio-label"><input type="radio" name="agreeToChangeLine"  {if $info['content_parameter']['groupAgreement']['agreeToChangeLine']==1}checked="checked"{/if} value="1">是</label>
                                <label class="radio-label ml-20"><input type="radio" name="agreeToChangeLine"  {if $info['content_parameter']['groupAgreement']['agreeToChangeLine']==0}checked="checked"{/if} value="0">否</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">是否同意解除合同：</span>
                            <div class="item-bd">
                                <label class="radio-label"><input type="radio" name="agreeToTerminate"  {if $info['content_parameter']['groupAgreement']['agreeToTerminate']==1}checked="checked"{/if} value="1">是</label>
                                <label class="radio-label ml-20"><input type="radio" name="agreeToTerminate"  {if $info['content_parameter']['groupAgreement']['agreeToTerminate']==0}checked="checked"{/if} value="0">否</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">是否同意拼团：</span>
                            <div class="item-bd">
                                <label class="radio-label"><input type="radio" name="agreeToMerge"  {if $info['content_parameter']['groupAgreement']['agreeToMerge']==1}checked="checked"{/if} value="1">是</label>
                                <label class="radio-label ml-20"><input type="radio" name="agreeToMerge"  {if $info['content_parameter']['groupAgreement']['agreeToMerge']==0}checked="checked"{/if} value="0">否</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">受委托社信息：</span>
                            <div class="item-bd">
                                <input type="text" name="transferToCompanyName" data-required="true" value="{$info['content_parameter']['groupAgreement']['transferToCompanyName']}" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">拼团旅行社名称：</span>
                            <div class="item-bd">
                                <input type="text" name="mergeToCompanyName" data-required="true" value="{$info['content_parameter']['groupAgreement']['mergeToCompanyName']}" class="input-text w900">
                            </div>
                        </li>
<!--                        <li class="12301">-->
<!--                            <label>导游部分tourGuides</label>-->
<!--                        </li>-->
                        {if $info['content_parameter']['tourGuides']}
                        {loop $info['content_parameter']['tourGuides'] $m}
                        <li class="12301">
                            <span class="item-hd">导游姓名：</span>
                            <div class="item-bd">
                                <input type="text" name="tourGuides_name" data-required="true" value="{$m['name']}" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">电话号码：</span>
                            <div class="item-bd">
                                <input type="text" name="tourGuides_phone" data-required="true" value="{$m['phone']}" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">导游证号：</span>
                            <div class="item-bd">
                                <input type="text" name="tourGuideID" data-required="true" value="{$m['tourGuideID']}" class="input-text w900">
                            </div>
                        </li>
                        {/loop}
                        {else}
                        <li class="12301">
                            <span class="item-hd">导游姓名：</span>
                            <div class="item-bd">
                                <input type="text" name="tourGuides_name" data-required="true" value="" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">电话号码：</span>
                            <div class="item-bd">
                                <input type="text" name="tourGuides_phone" data-required="true" value="" class="input-text w900">
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">导游证号：</span>
                            <div class="item-bd">
                                <input type="text" name="tourGuideID" data-required="true" value="" class="input-text w900">
                            </div>
                        </li>
                        {/if}

                        <li class="12301">
                            <span class="item-hd">行程：</span>
                            <div class="item-bd">
                                <label>*行程内容在游客针对具体产品下单时生成，查看生成的合同数据内容</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">游客名单：</span>
                            <div class="item-bd">
                                <label>*游客名单在游客针对具体产品下单时生成，查看生成的合同数据内容</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">签署人/游客代表：</span>
                            <div class="item-bd">
                                <label>*签署人/游客代表在游客针对具体产品下单时生成，查看生成的合同数据内容</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">费用：</span>
                            <div class="item-bd">
                                <label>*签署人/游客代表在游客针对具体产品下单时生成，查看生成的合同数据内容</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">保险：</span>
                            <div class="item-bd">
                                <label>*签署人/游客代表在游客针对具体产品下单时生成，查看生成的合同数据内容</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">自费项目：</span>
                            <div class="item-bd">
                                <label>*签署人/游客代表在游客针对具体产品下单时生成，查看生成的合同数据内容</label>
                            </div>
                        </li>
                        <li class="12301">
                            <span class="item-hd">购物：</span>
                            <div class="item-bd">
                                <label>*签署人/游客代表在游客针对具体产品下单时生成，查看生成的合同数据内容</label>
                            </div>
                        </li>
                        <!--12301合同内容-->
                    </ul>

                </div>
                <input type="hidden" id="id" name="id" value="{$info['id']}">
            </form>
            <div class="clear clearfix pt-20 pb-20">
                <a class="btn btn-primary radius size-L ml-115" id="save_btn" href="javascript:;">保存</a>
            </div>
        </td>
    </tr>
</table>

<script>
    //保存状态
    window.is_saving = 0;
    var ctype=1;
    $(document).ready(function(e) {
        window.content=window.JSEDITOR('txt_content');
        window.content=window.JSEDITOR('supplementaryClause_content');
        window.content.ready(function(){
            //window.content.setHeight(400);
        })


        $("#product_fm input").st_readyvalidate();

        $("#save_btn").click(function(e) {
            //检测是否是在保存状态
            if(is_saving == 1){
                return false;
            }
            window.is_saving = 1;
            if(ctype==1){
                var classstr="#product_fm .zidingyi input,.truename input";
            }else {
                var classstr="#product_fm .12301 input,.truename input";
            }
            var validate=$(classstr).st_govalidate({require:function(element,index){
                $(element).css("border","1px solid red");
                if(index==1)
                {
                    var switchDiv=$(element).parents(".product-add-div").first();
                    if(switchDiv.is(":hidden")&&!switchId)
                    {
                        var switchId=switchDiv.attr('id');
                        var columnId=switchId.replace('content','column');
                        $("#"+columnId).trigger('click');
                    }

                }
            }});
            if(validate==true)
            {
                ST.Util.showMsg('保存中',6,10000);
                $.ajaxform({
                    url   :  SITEURL+"contract/admin/contract/ajax_save",
                    method  :  "POST",
                    form  : "#product_fm",
                    dataType  :  "html",
                    success  :  function(result)
                    {
                        var text = result;
                        if(window.isNaN(text))
                        {
                            ZENG.msgbox._hide();
                            ST.Util.showMsg('保存失败',5);
                        }
                        else
                        {
                            // Ext.get('line_id').setValue(text);
                            $("#id").val(text);
                            ST.Util.showMsg('保存成功',4)
                        }
                        window.is_saving = 0;
                    }});

            }
            else
            {
                ST.Util.showMsg("请将信息填写完整",1,1200);
                window.is_saving = 0;
            }
        });

        //合同内容切换
        var options = $("#type option:selected").val();
        console.log({$info});
        if(options==1){
            $(".12301").hide();
        }else{
            $(".zidingyi").hide();
        }
        $("#type").change(function (e) {
            var type=$(this).val();
            if(type==1)
            {
                $(".12301").hide();
                $(".zidingyi").show();
                ctype=1;
            }else{
                $(".zidingyi").hide();
                $(".12301").show();
                ctype=2;
            }
        });
        //上传签章
        $('#fx_logo_btn').click(function () {
            ST.Util.showBox('上传图片', SITEURL + 'image/insert_view', 0, 0, null, null, document, {
                loadWindow: window,
                loadCallback: Insert
            });

            function Insert(result, bool) {
                var len = result.data.length;
                for (var i = 0; i < len; i++) {
                    var temp = result.data[i].split('$$');
                    var html = "<img class='up-img-area' src='" + temp[0] + "' />";
                    html += "<input type='hidden' name='stamp' value='" + temp[0] + "'/>"
                    $("#fx_logo_pic").html(html);
                }
            }
        })
    });

</script>



</body>
</html>
